import java.util.Scanner;

public class JavaClass {



    //1.判断一个数是奇数还是偶数

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        judge(in.nextInt());
        in.close();
    }

    public static void judge(int x){
        if (x != 0){
            if (x % 2 == 0){
                System.out.println("偶数!");
            } else if (x % 2 != 0) {
                System.out.println("奇数!");
            }
        }else {
            System.out.println("非奇非偶!");
        }
    }



    //2.判断是否是闰年

    public static void main2(String[] args) {
        System.out.print("请输入年份: ");
        Scanner in = new Scanner(System.in);
        leap(in.nextInt());
        in.close();
    }

    public static void leap(int x){
        if (x >= 0) {
            if (x % 4 == 0 && x % 100 != 0 || x % 400 ==0){
                System.out.println("是闰年!");
            }else {
                System.out.println("不是闰年!");
            }
        }
    }




    //3.找出4个整数的最大与最小的数字

    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        find(in.nextInt(),in.nextInt(),in.nextInt(),in.nextInt());
        in.close();
    }

    public static int find(int x, int y, int z, int k) {
        int max = x;
        int min = x;

        if (y > max) max = y;
        if (z > max) max = z;
        if (k > max) max = k;
        if (y < min) min = y;
        if (z < min) min = z;
        if (k < min) min = k;

        System.out.println("max: " + max);
        System.out.println("min: " + min);
        return 0;
    }




    //4.计算一元二次方程的两根

    public static void main4(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入a,b,c的值: ");
        root(in.nextInt(),in.nextInt(),in.nextInt());
        in.close();
    }

    public static void root(int a, int b, int c){
        double p = b*b - 4*a*c;
        double n = Math.sqrt(p);
        double m1 = (-b + n) / 2*a;
        double m2 = (-b - n) / 2*a;
        if(p == 0){
            System.out.println("只有一个根" + m1);
        } else if (p < 0 || a == 0) {
            System.out.println("无根!");
        } else if (p > 0) {
            System.out.println("根1: " + m1);
            System.out.println("根2: " + m2);
        }
    }




    //5.输入数字输出对应季节

    public static void main5(String[] args) {
        System.out.print("请输入数字: ");
        Scanner in = new Scanner(System.in);
        sea(in.nextInt());
        in.close();
    }

    public static void sea(int a){
        if(a > 0 && a < 13){
            if(a>1 && a <= 4){
                System.out.println("春天!");
            } else if (a > 4 && a <= 7) {
                System.out.println("夏天!");
            } else if (a > 7 && a <= 10) {
                System.out.println("秋天!");
            }else {
                System.out.println("冬天!");
            }
        }else {
            System.out.println("请输入1-12的数字!!!");
        }
        return ;

    }




    //6.输入百分制分数,输出等级

    public static void main6(String[] args) {
        Scanner in = new Scanner(System.in);
        double n = in.nextDouble();
        if (n >= 0 && n <= 100) {
            if (n >= 85) {
                System.out.println("优秀!");
            } else if (n >= 70) {
                System.out.println("良好!");
            } else if (n >= 60) {
                System.out.println("及格!");
            }else {
                System.out.println("不及格!");
            }
        } else {
            System.out.println("请输入100以内的数!!!");
        }
    }




    //7.接收输入的数字,输出最大与最小的数字

    public static void main7(String[] args) {
        Scanner scanner = new Scanner(System.in);              //标准输入

        Scanner time = new Scanner(System.in);                 //你要输出数字的个数
        System.out.println("你要输入几个整数：");
        int p = time.nextInt();                                //个数赋值给p
        int[] num = new int[p];                                //创建空间大小为p的数组

        if (p > 1) {                                           //判断数字是否大于等于2个,满足大小值的比较
        for (int i = 0; i < p; i++) {                          //循环输入数字
            System.out.print("请输入第" + (i + 1) + "个整数：");
            num[i] = scanner.nextInt();                        //依次填进数组中
        }

        // 初始化最大值和最小值为数组的第一个元素
        int max = num[0];
        int min = num[0];

            for (int i = 1; i < num.length; i++) {              //循环求最大值
                if (num[i] > max) {
                    max = num[i];
                }
                if (num[i] < min) {                             //循环求最小值
                    min = num[i];
                }
            }

            // 输出结果
            System.out.println("最大值是：" + max);
            System.out.println("最小值是：" + min);
        }else {
            System.out.println("请输入2个以上的数字!!!");
        }

        scanner.close();
    }




    //8.显示100~1000能被5和6整除的所有数字,每行打印10个数,之间用空格隔开

    public static void main8(String[] args) {
        System.out.println("求100~1000以内可以被5和6整除的数");
        System.out.println("=======================================");

        int count = 0;                        //计每行打印个数

        for (int i = 100; i <= 1000; i++) {
            if (i % 5 == 0 && i % 6 == 0) {
                System.out.print(i + " ");
                count++;                      //打印一个数count+1
                if (count % 10 == 0) {        //取模判断每行是否打印了10个数
                    System.out.println();
                }
            }
        }
        System.out.println("=======================================");
    }





    //9.输出1~1000中有7或者是7的倍数的数,求出个数并求和

    public static void main9(String[] args) {
        int count = 0;
        int sum = 0;

        for (int i = 1; i <= 1000; i++) {
            if (containsSeven(i) || i % 7 == 0) {
                System.out.printf("%-4d",i);      //格式化打印用printf, %4d指每个数占4个空间,-号指对齐左边
                count++;
                sum += i;

                if (count % 10 == 0) {
                    System.out.println();
                }
            }
        }

        if (count % 10 != 0) {
            System.out.println();
        }

        System.out.println("个数：" + count);
        System.out.println("总和：" + sum);
    }

    public static boolean containsSeven(int number) {
        int temp = number;
        while (temp > 0) {
            if (temp % 10 == 7) {
                return true;
            }
            temp /= 10;
        }
        return false;
    }




    //10.输入年份,输出生肖

    public static void main10(String[] args) {
        Scanner in = new Scanner(System.in);
        int year = in.nextInt();
        if (year > 0 && year % 1 == 0){
            String n = zodiac(year);
            System.out.println(year + "年的生肖是: " + n);
        }else {
            System.out.println("请输入正确的年份(正整数)!!!");
        }
        in.close();
    }

    public static String zodiac(int year){
        String[] sym = {"鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"};

        int x = (year - 1900) % 12;
        if (x < 0){
            x += 12;
        }
        return sym[x];
    }













}
